package com.itcaius.weblog.web.convert;

import com.itcaius.weblog.common.domain.dos.ArticleDO;
import com.itcaius.weblog.web.model.vo.article.FindIndexArticlePageListRspVO;
import com.itcaius.weblog.web.model.vo.category.FindCategoryArticlePageListRspVO;
import com.itcaius.weblog.web.model.vo.tag.FindTagArticlePageListReqVO;
import com.itcaius.weblog.web.model.vo.tag.FindTagArticlePageListRspVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author Caius
 * @description
 * @since Created in 2025-04-30
 */
@Mapper
public interface ArticleConvert {

    /**
     * 实例化 ArticleConvert
     */
    ArticleConvert INSTANCE = Mappers.getMapper(ArticleConvert.class);

    /**
     * DO 转换 VO
     * @param bean
     * @return
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindIndexArticlePageListRspVO convertDO2VO(ArticleDO bean);

    /**
     * 将 DO 转换为分类文章 DO
     * @param bean
     * @return
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindCategoryArticlePageListRspVO convertDO2CategoryArticleVO(ArticleDO bean);

    /**
     * ArticleDO -> FindTagArticlePageListRspVO
     * @param bean
     * @return
     */
    @Mapping(target = "createDate", expression = "java(java.time.LocalDate.from(bean.getCreateTime()))")
    FindTagArticlePageListRspVO convertDO2TagArticleVO(ArticleDO bean);
}
